package com.gaga.console.core.service.impl.ai;

import com.gaga.common.enums.PolishOrQaType;
import com.gaga.console.core.entity.dto.ChatDto;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liujia
 * @version 1.0
 * @date 2025/4/9-10:03
 */
public abstract class AbstractAiHandler implements AiHandler {

    protected String polishPromptText;

    protected void init(String polishPromptText) {
        this.polishPromptText = polishPromptText;
    }

    /**
     * 构建提示词
     *
     * @param dto
     * @return
     */
    protected String buildPromptMessage(ChatDto dto) {
        StringBuilder promptBuilder = new StringBuilder();
        if (StringUtils.isNotBlank(dto.getBlockWords())) {
            promptBuilder.append("屏蔽词：");
            promptBuilder.append(dto.getBlockWords());
        }
        if (PolishOrQaType.POLISH.equals(dto.getPolishOrQaType())) {
            promptBuilder.append("以下为需要修改的话术：");
        }
        promptBuilder.append(dto.getMessage());
        return promptBuilder.toString();
    }
}
